select * FROM dbo.DBMMReplications where ReplicationID=270

select * FROM DBMoto_Repo_YCHOI.dbo.DBMMTables
where TableID in (473, 245)

SELECT [FieldMappingID]
      ,[ReplicationID]
      ,[IsForth]
      ,[TrgFieldID]
      ,[SrcFieldID]
      ,[SrcExpression]
  FROM [dbo].[DBMMFieldMappings]
  where [ReplicationID]=270
GO


where TableID in (select SrcTableID FROM DBMoto_Repo_YCHOI.dbo.DBMMReplications where )



use [DBMoto_Repo_YCHOI]
go

SELECT FM.[FieldMappingID]
      ,FM.[ReplicationID]
      ,FM.[IsForth]
      ,FM.[TrgFieldID]
	  ,FT.Name as [Trg Fields Name]
      ,FM.[SrcFieldID]
	  ,FS.Name as [Src Fields Name]
      ,FM.[SrcExpression]
  FROM 
	[dbo].[DBMMFieldMappings] as FM, 
	[dbo].[DBMMFields] as FS,
	[dbo].[DBMMFields] as FT
  where 
  Fm.ReplicationID=270 and 
  FS.FieldID=FM.[SrcFieldID] and FT.FieldID=FM.[TrgFieldID] and 
  FM.[ReplicationID] in (select [ReplicationID] from dbo.DBMMReplications where 
  SrcTableID in (select TableID FROM dbo.DBMMTables )) OR FM.[SrcFieldID] is null
  Order By FM.ReplicationID;
GO




